dynamics_data = {
    "155-DTM": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],
    [750.0, 363.5057471264368, 408.80079284902195, 435.3448275862069, 462.6436781609196, 462.35795454545456, 471.264367816092, 451.24350555006237, 401.02675179762593, 352.4077041741376, 330.06878830032144, 750.0, 750.0, 750.0, 750.0, 711.6161949594086, 667.1401827744456, 627.8966426112429, 593.0134957995072, 561.8022591784805, 533.7121462195564]],
    "acura-nsx-sz": [[0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000],
    [280, 300, 350, 390, 430, 430, 450, 450, 460, 460, 460, 440, 420, 390, 360, 350, 340, 320, 300, 280, 250]],
    "baja-bug": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],
    [2000.0, 150.60536398467436, 160.51027785254712, 177.2462587670076, 177.3406511327918, 156.87826830977735, 109.13270838941034, 75.0287370177196, 42.145593869731805, 1186.8182037348374, 1068.1363833613536, 971.0330757830488, 890.1136528011281, 821.643371816426, 762.9545595438242, 712.0909222409025, 667.5852396008461, 628.3155196243257, 593.4091018674187, 562.1770438743966, 534.0681916806768]],
    "buggy": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],
    [2000.0, 193.25583777291413, 254.64298624195746, 345.58690989979937, 384.2380774543822, 363.7756946313678, 297.8413499794324, 229.6334072360509, 181.8878473156839, 1186.8182037348374, 1068.1363833613536, 971.0330757830488, 890.1136528011281, 821.643371816426, 762.9545595438242, 712.0909222409025, 667.5852396008461, 628.3155196243257, 593.4091018674187, 562.1770438743966, 534.0681916806768]],
    "car1-ow1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000],
    [100, 100, 120, 140, 160, 180, 220, 260, 300, 340, 340, 340.0, 340.0, 345.0, 350.0, 355.0, 360.0, 360.0, 360.0, 330.0, 300.0]],
    "car1-stock1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [100, 200, 333, 420, 520, 640, 670, 710, 690, 663, 590]],
    "car1-stock2": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [100, 290, 390, 480, 560, 640, 650, 640, 600, 560, 500]],
    "car1-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [100.0, 160.0, 190.0, 280.0, 350, 405.0, 443.0, 465.0, 483.0, 415.0, 360.0]],
    "car1-trb3": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [100.0, 160.0, 190.0, 240.0, 300.0, 350, 405, 435, 430, 370, 293]],
    "car2-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [100.0, 220.0, 310.0, 370.0, 420.0, 460.0, 490.0, 500.0, 485.0, 428.0, 310.0]],
    "car3-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [90.0, 230.0, 350.0, 450.0, 530.0, 520.0, 500.0, 475.0, 450.0, 415.0, 369.0]],
    "car4-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [80.0, 190.0, 230.0, 330.0, 405.0, 475.0, 505.0, 515.0, 480.0, 410.0, 330.0]],
    "car5-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [97.0, 222.0, 325.0, 470.0, 560.0, 555.0, 545.0, 511.0, 471.0, 410.0, 320.0]],
    "car6-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [91.0, 287.0, 377.0, 455.0, 493.0, 517.0, 523.0, 502.0, 473.0, 347.98, 185.10]],
    "car7-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [91.0, 287.0, 377.0, 455.0, 492.0, 517.0, 501.0, 492.0, 453.0, 333.98, 185.10]],
    "car8-trb1": [[0, 1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000],
    [97.0, 222.0, 325.0, 470.0, 560.0, 555.0, 545.0, 521.0, 471.0, 410.0, 320.0]],
    "kc-2000gt": [[0.000000, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000],
    [0, 140, 150, 150, 155, 160, 165, 168, 172, 175, 177, 172, 167, 161, 152, 142, 132, 130, 0.000000, 0.000000, 0.000000]],
    "kc-5300gt": [[0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000],
    [0, 110, 170, 260, 350, 430, 475, 488, 480, 470, 460, 445, 415, 380, 335]],
    "kc-110": [[0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000],
    [0, 60, 75, 87, 98, 109, 115, 118, 120, 122, 121.6, 121.2, 120.8, 120.4, 120, 107, 95, 80, 64, 0, 0]],
    "p406": [[0, 500, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000, 5500, 6000, 6500, 7000],
    [20, 60, 110, 110, 140, 167, 195, 220, 240, 260, 255, 250, 220, 200, 160]],
    "pw-imprezawrc": [[0, 1024, 2048, 3072, 4096, 5120, 5888, 7168, 8192, 9216, 10240],
    [100, 317, 339, 355, 415, 452, 482, 438, 364, 210, 147]],
    "pw-focuswrc": [[0, 1024, 2048, 3072, 4096, 5120, 5888, 7168, 8192, 9216, 10240],
    [100, 217, 339, 365, 461, 466, 472, 428, 354, 200, 147]],
    "pw-evoviwrc": [[0, 1024, 2048, 3072, 4096, 5120, 5888, 7168, 8192, 9216, 10000],
    [0, 230, 345, 395, 461, 471, 472, 458, 354, 200, 147]],
    "pw-206wrc": [[0, 1024, 2048, 3072, 4096, 5120, 5888, 7168, 8192, 9216, 10000],
    [100, 247, 369, 395, 466, 472, 467, 458, 384, 230, 177]],
    "pw-corollawrc": [[0, 1024, 2048, 3072, 4096, 5120, 5888, 7168, 8192, 9216, 10000],
    [100, 227, 310, 375, 471, 472, 462, 438, 364, 210, 157]],
    "pw-306wrc": [[0, 1024, 2048, 3072, 4096, 5120, 5888, 7168, 8192, 9216, 10000],
    [100, 247, 369, 395, 456, 462, 458, 445, 384, 230, 177]]
}

import matplotlib.pyplot as plt

def generate_plots():
    for car in dynamics_data.keys():
        rpm = dynamics_data[car][0]
        torque = dynamics_data[car][1]
        plt.figure()
        plt.plot(rpm, torque)
        plt.title(car)
        plt.xlabel('rpm')
        plt.ylabel('torque (N.m)')
        plt.savefig(car+'.png')


cars_to_compare = [
    "car1-stock1",
    "car1-stock2",
    "155-DTM",
    "car3-trb1",
    "kc-2000gt",
    "buggy",
    "baja-bug"
]


def plot_to_compare():
    plt.figure()
    for car in cars_to_compare:
        rpm = dynamics_data[car][0]
        torque = dynamics_data[car][1]
        plt.plot(rpm, torque)
    plt.title("Engine responses compared (Train)")
    plt.xlabel('rpm')
    plt.ylabel('torque (N.m)')
    plt.legend(cars_to_compare)
    plt.savefig('engine_responses_train.png')

if __name__=='__main__':
    # generate_plots()
    plot_to_compare()